<template>
  <div class="top-bar">
    <div class="logo" @click="go">
      <svg>
        <use xlink:href="#icon-lanqiu"></use>
      </svg>
    </div>
    <div class="btns">
      <span style="margin-right: 50px" @click="doc">文档</span>
      <!-- <span>菜单</span> -->
    </div>
    <!-- 更多图片 -->
    <div class="icon" v-if="ismore" @click="changemenuVisible"></div>
  </div>
</template>
<script lang="ts">
import { defineComponent, inject, Ref, onMounted } from "vue";
import { useRouter } from "vue-router";
export default defineComponent({
  setup() {
    const menuVisible = inject<Ref<boolean>>("menuVisible"); //获取是否显示aside的布尔值
    const router = useRouter();
    let ismore = true; //是否显示更多
    if (router.currentRoute.value.fullPath == "/Home") {
      // 首页把更多图标隐藏掉
      ismore = false;
    } else {
      ismore = true;
    }
    //改变aside函数
    const changemenuVisible = () => {
      menuVisible.value = !menuVisible.value;
    };
    const go = () => {
      router.push({
        path: "/",
      });
    };
    const doc = () => {
      router.push({
        path: "/doc/Intro",
      });
    };
    return { go, doc, ismore, changemenuVisible };
  },
});
</script>
<style lang="scss" scoped>
.top-bar {
  padding: 16px;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background-color: #fff;
  box-shadow: 0 5px 5px rgb(51 51 51 / 10%);
  display: flex;
  // padding: 16px;
  z-index: 20;
  color: #6f2e6a;
  //   justify-content: center;
  align-items: center;
}
.logo {
  margin: 0 auto;
  cursor: pointer;
  margin-left: 30px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  svg {
    width: 100%;
    height: 100%;
  }
}
.icon {
  display: none;
  width: 30px;
  height: 30px;
  background-image: url("../assets/icon1.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.btns {
  margin-right: 50px;
  font-size: 15px;
  cursor: pointer;
  font-weight: bold;
}

@media (max-width: 500px) {
  .btns {
    display: none;
  }
  .logo {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    svg {
      width: 100%;
      height: 100%;
    }
  }
  .top-bar {
    padding: 16px 0px;
  }
  .icon {
    display: block;
    position: absolute;
    left: 35px;
    top: 20px;
  }
}
</style>